package com.distributedDataBase.service;

import com.distributedDataBase.mapper.CartMapper;
import com.distributedDataBase.pojo.Cart;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CartServiceImpl implements CartService {

    @Autowired
    private CartMapper cartMapper;

    @Override
    public List<Cart> listAll() {
        return cartMapper.findAll();
    }

    @Override
    public List<Cart> listByUserId(Integer userId) {
        return cartMapper.findByUserId(userId);
    }

    @Override
    public int delCart(Integer id, Integer userId) {
        return cartMapper.delCart(id, userId);
    }

    @Override
    public int altTotal(Integer id, Integer userId, Integer total) {
        return cartMapper.altTotal(id, userId, total);
    }

    @Override
    public int addCart(Cart cart) {
        return cartMapper.addCart(cart);
    }

    @Override
    public Cart getByUidAndPid(Integer uid, Integer pid) {
        return cartMapper.getByUidAndPid(uid, pid);
    }
}
